package com.fbee.smartcommunities.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.fbee.smartcommunities.entity.ConsumptionLogs;
import com.fbee.smartcommunities.entity.Log;
import com.fbee.smartcommunities.service.ConsumptionLogsService;
import com.fbee.smartcommunities.service.LogService;
import com.fbee.smartcommunities.vo.ResultVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 汪佳泉
 * @since 2024-08-28
 */
@RestController
@RequestMapping("/consumptionLogs")
public class ConsumptionLogsController {

    @Resource
    private ConsumptionLogsService consumptionLogsService;

    // 分页后内容
    @GetMapping("/list")
    public ResultVO<IPage<ConsumptionLogs>> getPage(Integer pageNo, Integer pageSize, String keyword) {
        return ResultVO.success(consumptionLogsService.getPage(pageNo,pageSize,keyword));
    }

    @GetMapping("/listNoPage")
    public ResultVO<List<ConsumptionLogs>> getList(Long openId){
        return ResultVO.success(consumptionLogsService.list(new QueryWrapper<ConsumptionLogs>().eq("user_id",openId).orderByDesc("time")));
    }

}
